# Maintainer: Alberto Fanjul Alonso <albfan@gnome.org>

_realname=gitg
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=44
pkgrel=3
pkgdesc="git repository viewer for GTK+/GNOME (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://wiki.gnome.org/Apps/Gitg"
msys2_repository_url="https://gitlab.gnome.org/GNOME/gitg"
license=("spdx:GPL-2.0-or-later")
depends=("${MINGW_PACKAGE_PREFIX}-adwaita-icon-theme"
         "${MINGW_PACKAGE_PREFIX}-gtksourceview4"
         "${MINGW_PACKAGE_PREFIX}-libpeas"
         "${MINGW_PACKAGE_PREFIX}-enchant"
         "${MINGW_PACKAGE_PREFIX}-iso-codes"
         "${MINGW_PACKAGE_PREFIX}-python3-gobject"
         "${MINGW_PACKAGE_PREFIX}-gsettings-desktop-schemas"
         "${MINGW_PACKAGE_PREFIX}-gtk-update-icon-cache"
         "${MINGW_PACKAGE_PREFIX}-libsecret"
         "${MINGW_PACKAGE_PREFIX}-gspell"
         "${MINGW_PACKAGE_PREFIX}-libgit2-glib"
         "${MINGW_PACKAGE_PREFIX}-gettext-runtime"
         "${MINGW_PACKAGE_PREFIX}-libdazzle"
         "${MINGW_PACKAGE_PREFIX}-libgee"
         "${MINGW_PACKAGE_PREFIX}-gpgme"
         "${MINGW_PACKAGE_PREFIX}-libhandy")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-pkgconf"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-gettext-tools"
             "${MINGW_PACKAGE_PREFIX}-itstool")
source=("https://download.gnome.org/sources/${_realname}/${pkgver}/${_realname}-$pkgver.tar.xz")
sha256sums=('342a31684dab9671cd341bd3e3ce665adcee0460c2a081ddc493cdbc03132530')

build() {
  mkdir -p build-${MSYSTEM} && cd build-${MSYSTEM}

  # clang error from vala generated file
  export CFLAGS="${CFLAGS} -Wno-incompatible-function-pointer-types"
  # gcc errors from vala generated file
  CFLAGS+=" -Wno-incompatible-pointer-types"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  ${MINGW_PREFIX}/bin/meson setup \
    --prefix="${MINGW_PREFIX}" \
    --buildtype plain \
    -Dwerror=false \
    ../${_realname}-${pkgver}

  ${MINGW_PREFIX}/bin/meson compile
}

package() {
  cd "$srcdir/build-${MSYSTEM}"
  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/meson install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
